package com.ruoyi.web.controller.common;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysAttachCate;
import com.ruoyi.system.service.ISysAttachCateService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 素材分类Controller
 * 
 * @author ruoyi
 * @date 2023-04-10
 */
@RestController
@RequestMapping("/system/attach-cate")
public class SysAttachCateController extends BaseController
{
    @Resource
    private ISysAttachCateService sysAttachCateService;

    /**
     * 查询素材分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysAttachCate sysAttachCate)
    {
        startPage();
        List<SysAttachCate> list = sysAttachCateService.selectSysAttachCateList(sysAttachCate);
        return getDataTable(list);
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(SysAttachCate sysAttachCate)
    {
        return success(sysAttachCateService.selectSysAttachCateList(sysAttachCate));
    }



    /**
     * 获取素材分类详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysAttachCateService.selectSysAttachCateById(id));
    }


    @PostMapping
    public AjaxResult add(@RequestBody SysAttachCate sysAttachCate)
    {
        return toAjax(sysAttachCateService.insertSysAttachCate(sysAttachCate));
    }


    @PutMapping
    public AjaxResult edit(@RequestBody SysAttachCate sysAttachCate)
    {
        return toAjax(sysAttachCateService.updateSysAttachCate(sysAttachCate));
    }

    /**
     * 删除素材分类
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAttachCateService.deleteSysAttachCateByIds(ids));
    }
}
